import Vue from 'vue'
import VueRouter from 'vue-router'
import Index from '../views/Index.vue'
Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Home',
    component:Index,
    meta:{
      title:"可米克斯动漫(*^▽^*)"
    },
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Login.vue'),
    meta:{
      title:"可米克斯动漫^_^"
    },
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import('@/views/Register.vue'),
    meta:{
      title:"可米克斯动漫(#^.^#)"
    },
  },
  {
    path: '/video/:kw/:vid',
    name: 'Video',
    props:true,
    component: () => import('@/views/Video.vue'),
  },
  {
    path: '/search/:kw',
    name: 'Search',
    props:true,
    component: () => import('@/views/Search.vue'),
  },
]

const router = new VueRouter({
  mode: 'hash',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to,from,next)=>{
  document.title=to.meta.title||"可米克斯动漫"
  next()
})

const VueRouterPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (to) {
  return VueRouterPush.call(this, to).catch(err => err)
}

export default router
